package cn.zyy.jdbc;

import cn.zyy.utils.JDBCUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class JDBCDemo04 {
    public static void main(String[] args) {
        Connection conn = JDBCUtil.getConnection();
        String sql = "delete from usr where id = ?";
        PreparedStatement pstmt = null;
        try {
            pstmt= conn.prepareStatement(sql);
            pstmt.setInt(1,2);
            int i = pstmt.executeUpdate();
            System.out.println("i = " + i);
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            JDBCUtil.closeAll(null,pstmt,conn);
        }
    }
}
